# -*- coding:utf-8 -*-
from django.db import models
from django.core.urlresolvers import reverse
from ckeditor.fields import RichTextField

# Create your models here.
class Tag(models.Model):
	tag_name = models.CharField(max_length=64)
	def __unicode__(self):
		return self.tag_name

class BlogContent(models.Model):
	"""创建博客模块"""
	title = models.CharField(u'标题', max_length = 30)					#标题
	label = models.CharField(u'标签', max_length = 50, blank = True)		#标签
	date_time = models.DateTimeField(auto_now_add = True)		#日期
	# content = models.TextField(u'正文', blank = True, null = True)		#正文
	content = RichTextField('正文')		#正文


	def get_absolute(self):
		path = reverse('detail', kwargs={'id':self.id})
		return "http://127.0.0.1:8000%s"%path


	def __unicode__(self):
		return self.title

	class Meta:		#按时间下降排序
		ordering = ['-date_time']
		verbose_name = '博客'
		verbose_name_plural = '创建博客'
		